const findDisappearedNumbers = function(nums) {
    const len = nums.length;
    for (let i = 0; i < len; i++) {
        let j = Math.abs(nums[i]);
        if (nums[j - 1] > 0) {
            // 标记为负数
            nums[j - 1] *= -1;
        }
    }
    let res = [];
    for (let i = 0; i < len; i++) {
        if (nums[i] > 0) {
            // 最终，nums 数组中未标记为负数的索引，即是未出现过的数字 - 1
            res.push(i + 1);
        }
    }
    return res;
};

const nums = [4, 3, 2, 7, 8, 2, 3, 1];  // output: [5, 6]
const res = findDisappearedNumbers(nums);
console.log(res);
